Introduce extensible configuration fetcher SPI for JCasC#2865
Introduce extensible configuration fetcher SPI for JCasC#2865somiljain2006 wants to merge 13 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a new Service Provider Interface (SPI) for resolving and fetching JCasC YAML configurations from extensible sources, with default fetchers for local filesystem paths and HTTP(S) URLs, plus lifecycle-managed cleanup via FetchResult/FetchContext. This refactors ConfigurationAsCode to use the new fetch pipeline and adds tests around fetcher behavior and resource cleanup.
Changes:
- Add
CasCConfigFetcherSPI and core fetch pipeline primitives (ResolvedYaml,FetchResult,FetchContext). - Refactor
ConfigurationAsCodeconfiguration loading to fetch YAML via registered fetchers and manage resource lifecycles. - Add unit/integration tests for filesystem and HTTP fetchers and for lifecycle cleanup behavior.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test-harness/src/test/java/io/jenkins/plugins/casc/ConfigurationAsCodeTest.java | Updates tests to run with a Jenkins rule where new code requires a Jenkins instance. |
| plugin/src/test/java/io/jenkins/plugins/casc/fetcher/LocalFileSystemFetcherTest.java | Verifies local filesystem fetcher supports/scan behavior. |
| plugin/src/test/java/io/jenkins/plugins/casc/fetcher/FetchResultTest.java | Tests FetchResult close/cleanup semantics. |
| plugin/src/test/java/io/jenkins/plugins/casc/fetcher/FetchContextTest.java | Tests deterministic sorting and cascading closure of results. |
| plugin/src/test/java/io/jenkins/plugins/casc/fetcher/DefaultHttpFetcherTest.java | Verifies HTTP fetcher support, filename derivation, and an integration fetch via embedded server. |
| plugin/src/test/java/io/jenkins/plugins/casc/fetcher/ConfigFetcherIntegrationTest.java | End-to-end wiring test for a custom fetcher extension and cleanup lifecycle. |
| plugin/src/test/java/io/jenkins/plugins/casc/fetcher/BootstrapEnvVarCredentialResolverTest.java | Tests env-var resolver behavior for missing/unsupported types. |
| plugin/src/main/java/io/jenkins/plugins/casc/yaml/YamlUtils.java | Adds support for reading from ResolvedYaml sources. |
| plugin/src/main/java/io/jenkins/plugins/casc/yaml/YamlSource.java | Adds named sources and a factory for ResolvedYaml. |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/ResolvedYaml.java | New abstraction for YAML items with an InputStream supplier. |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/LocalFileSystemFetcher.java | Default fetcher for files/directories (recursive scan). |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchResult.java | Resource + temp-directory cleanup wrapper for fetch results. |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchCredentialsProvider.java | Extension point for credential providers. |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchCredentials.java | Credential resolution façade (extensions + bootstrap env). |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchContext.java | Aggregates sources and ensures results are closed. |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/FetchAuthData.java | Credential data model (token/username+password/SSH key). |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/EnvVarFetchCredentialsProvider.java | Extension-backed env-var credential provider. |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/DefaultHttpFetcher.java | Default fetcher for HTTP(S) single-file YAML sources. |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/CasCConfigFetcher.java | SPI contract for config fetchers. |
| plugin/src/main/java/io/jenkins/plugins/casc/fetcher/BootstrapEnvVarCredentialResolver.java | Bootstrap credential resolver from environment variables. |
| plugin/src/main/java/io/jenkins/plugins/casc/ConfigurationAsCode.java | Refactors config loading to use fetchers and managed lifecycles. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@timja CI is failing during dependency resolution with:
I reran it and got the same error. Could you please check? |
|
Maybe this? jenkins-infra/helpdesk#5221 |
Fixes #2266
Introduce a pluggable configuration fetcher API that allows Configuration as Code to load YAML from extensible sources while preserving existing behavior. Add default fetchers for local filesystem paths and HTTP/HTTPS URLs, along with a credential-resolution abstraction and a bootstrap environment-variable provider. Refactor configuration loading to use the new fetcher pipeline with managed resource lifecycles, and add unit and integration tests covering fetchers, credential providers, resource cleanup, and end-to-end configuration loading.
Your checklist for this pull request
🚨 Please review the guidelines for contributing to this repository.